nginx配置thinkPHP
简介:
首先,thinkPHP框架默认情况下可以解析的url路由是:http://xx.com/index.php?s= 这个样子的
所以,配置里就是将访问的网址‘/’后面的东西解析成上述的模样,s=后面的东西就是我们要加的路由如:
http://xx.com/home/index/index
解析为
http://xx.com/index.php?s=home/index/index
配置如下
server {
listen 80 default_server; #设置监听内容,以及默认服务器
server_name www.zhangyaze.com; #设置域名
index index.php index.html; #设置默认访问的文件
root /home/wwwroot/目录/public; #设置根目录
include enable-php.conf; #引入php解析的conf文件,有的版本好像默认引入不用写
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / { #解析内容,将访问路径根据上述规则进行更换
index index.php;
# !!!url重写!!!
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}
踩坑记录之open_basedir()报错
踩坑过程:
配置完之后,打开网站,白屏,打开后台发现500报错,但是并没有显示信息。
于是我去找到php.ini
lnmp安装的默认位置在:/usr/local/php/etc/里面
修改“display_errors = Off”将改为“On”将报错信息打开,
提示报错,是open_basedir()的问题,说明
我设置的目录只允许访问public下的,而其他的东西加载不进来
那还有个屁用
所以,经过我的查找,在nginx目录下用以下命令,就找到了个东西
grep -rn open_basedir ./
在fastcgi.conf文件里面有一行
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/
反正约莫意思就是我设置的根目录下才是我的权限目录,所以,我打开加了个../,如下:
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/
重启nginx,万事大吉。
第一篇博客就留在这个thinkphp的身上吧。
封面图片封底:
The authors applied their algorithm on 50 patients undergoing routine coronary calcium assessment by CT. viagra brand name generic drug is there a generic viagra on the market